package com.chuanye.mydrawable.activitys;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.chuanye.mydrawable.R;
import com.chuanye.mydrawable.adapters.RepairInfoAdapter;
import com.chuanye.mydrawable.beans.RepairInfoBean;
import com.chuanye.mydrawable.beans.RepairInfoNumBean;
import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.List;

public class RepairDetailsActivity extends AppCompatActivity {
    private Context mContext;
    private List<RepairInfoNumBean.ListBean> listBeanList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_repair_details);
        setContentView(R.layout.repairserve_no_view1);
        Intent intent = getIntent();
        String RepairId = intent.getStringExtra("RepairId");
        getRepairList(RepairId);

    }

    /**
     * 获得报修数据列表中操作步骤的数字
     */
    private void getRepairList(String RepairId) {
        OkHttpUtils.post()
                .url("http://172.16.1.121:9001/api/RepairInfo")//用户登陆并做与设备关系处理
                .addParams("request.pageIndex", "0")//ZMX  LXQ
                .addParams("request.pagesSize", String.valueOf(Integer.MAX_VALUE))//q123456
                .addParams("RepairId",RepairId)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(okhttp3.Call call, Exception e, int id) {
                        Log.i("请求异常：",e.toString());

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.i("报修列表操作数请求数据：",response.toString());
                        Gson gson = new Gson();
                        String str = response.toString();
                        RepairInfoNumBean repairInfoNumBean = gson.fromJson(str,RepairInfoNumBean.class);
                        if (repairInfoNumBean.getList().size() > 0){
                            Log.i("刷新条数：",repairInfoNumBean.getList().size()+"");
                            listBeanList = repairInfoNumBean.getList();


                        }

                    }
                });
    }
}
